<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/global.jsp"%>

<div id="notEntityCategoryAddDiv" class="easyui-window" title="添加分类"
	style="width: 400px; height: 300px"
	data-options="iconCls:'icon-cog',modal:true,openAnimation:'fade',closeAnimation:'slide',cache:false,collapsible:false,minimizable:false,maximizable:false">
	<div class="content-wrapper">
		<form id="notEntityCategoryAddForm" method="post"
			style="padding: 10px;">
			<input id="notEntityCategoryAddForm-name" type="text" name="name"
				style="width: 100%;" /> <input id="notEntityCategoryAddForm-sort"
				name="sort" style="width: 100%;" value="0" /> <input
				id="notEntityCategoryAddForm-itemType" name="itemType"
				style="width: 100%;" /> <input id="notEntityCategoryAddForm-ckey"
				name="ckey" style="width: 100%;" /> <input name="entity"
				style="display: none;" value="0" /> <input type="button"
				value="添  加" onclick="$('#notEntityCategoryAddForm').submit();"
				style="float: right; margin-top: 10px;" />
			<div style="clear: both;"></div>
		</form>
	</div>
</div>

<script type="text/javascript">
	var notEntityCategoryAddForm_itemType = undefined;
	var notEntityCategoryAddForm_ckey = undefined;
	var notEntityCategoryAddForm_sort = undefined;
	var notEntityCategoryAddForm_name = undefined;
	$(function() {

		notEntityCategoryAddForm_sort = $('#notEntityCategoryAddForm-sort')
				.numberbox({
					buttonText : '排&nbsp;&nbsp;&nbsp;&nbsp;序',
					buttonAlign : 'left',
					precision : 2
				});

		notEntityCategoryAddForm_ckey = $('#notEntityCategoryAddForm-ckey')
				.textbox({
					buttonText : '类&nbsp;型&nbsp;&nbsp;KEY',
					buttonAlign : 'left'
				});

		notEntityCategoryAddForm_itemType = $(
				'#notEntityCategoryAddForm-itemType').combobox({
			buttonText : '所属资源类型',
			buttonAlign : 'left',
			valueField : 'id',
			textField : 'text',
			data : [ {
				"id" : 0,
				"text" : "全部资源类型",
				"selected" : true
			}, {
				"id" : 1,
				"text" : "视频"
			}, {
				"id" : 2,
				"text" : "音频"
			}, {
				"id" : 3,
				"text" : "文本"
			} ],
			onChange : function(newValue, oldValue) {

			}
		});

		notEntityCategoryAddForm_name = $('#notEntityCategoryAddForm-name')
				.textbox({
					buttonText : '名&nbsp;&nbsp;&nbsp;&nbsp;称',
					buttonAlign : 'left'
				});

		var notEntityCategoryAddDiv = $('#notEntityCategoryAddDiv').window({
			onBeforeClose : function() {

			},
			onClose : function() {
				notEntityCategoryAddDiv.panel('destroy');
				try {
					notEntityCategoryListDatagrid.datagrid('reload');
				} catch (e) {
				}
			}
		});

		$('#notEntityCategoryAddForm').form(
				{
					url : baseUrl + '/category/add',
					onSubmit : function() {
						var name = notEntityCategoryAddForm_name
								.textbox('getValue');
						var itemType = notEntityCategoryAddForm_itemType
								.combobox('getValue');
						var ckey = notEntityCategoryAddForm_ckey
								.textbox('getValue');
						// 				var sort = notEntityCategoryAddForm_sort.numberbox('getValue');

						if (!name) {
							$.messager.alert('提示', '请输入名称', 'warning');
							return false;
						}
						if (!itemType || itemType == '0') {
							$.messager.alert('提示', '请选择所属资源类型', 'warning');
							return false;
						}
						if (!ckey) {
							$.messager.alert('提示', '请选择输入类型KEY', 'warning');
							return false;
						}
					},
					success : function(data) {
						data = eval("(" + data + ")");
						if (data.responseCode == '000') {
							$.messager.alert('提示', '添加成功!', 'info');
						} else {
							$.messager.alert('提示', data.responseMessage,
									'error');
						}
					}
				});

	});
</script>